/*
 * @Author: moonwater 13812995013@163.com
 * @Date: 2025-02-28 14:28:23
 * @LastEditors: moonwater 13812995013@163.com
 * @LastEditTime: 2025-02-28 14:50:53
 * @FilePath: \盐师22Git仓库\day05\Test06.java
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
package day05;

public class Test06 {
    public static void main(String[] args) {
        int[] array={1,9,3,4,5};
        // int sum = getSum(array);
        // System.out.println(sum);
        int maxNumber = getMax(array);
        System.out.println("该数组的最大值是：" +maxNumber);
    }
    // public static int getSum(int[] arr){

    //     int sum =0;
    //     for (int i = 0; i < arr.length; i++) {
    //         sum += arr[i];
    //     }
    //     return sum;
    // }
    public static int getMax(int[] arr){
        int max = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > max) {
                max = arr[i];
            }
        }
        return max;
    }
    
}
